<?php
/*
 * @Author: lokei
 * @Date: 2022-10-07 16:17:35
 * @LastEditors: lokei
 * @LastEditTime: 2022-10-13 19:13:45
 * @Description: 
 */
namespace App\Http\Controllers\Pay\Income;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Pay\Income\IncomeModel;
use Illuminate\Http\Request;

class IncomeController extends Controller {
    public function list(Request $request) {
        if($request->input('store_id') != null && intval($request->input('store_id')) > 0) {
            $items = IncomeModel::where('store_id', '=', $request->input('store_id'))->get();
        } else {
            $items = IncomeModel::get();
        }
        $res = ResultTool::success();
        $res['data']['items'] = $items;
        $res['data']['total'] = count($items);
        return $res;
    }

    public function delete(Request $request) {
        IncomeModel::where('id', '=', $request->input('id'))->delete();
        return ResultTool::success();
    }
}